//
//  Dictionary.swift
//  Teamo
//
//  Created by mdzz on 2021/12/17.
//

import Foundation

extension Dictionary {
    public var string: String {
        let defaultJsonStr = "[]"
        if !JSONSerialization.isValidJSONObject(self) {
            return defaultJsonStr
        }
        print("self.\(self)")
        guard let data = try? JSONSerialization.data(withJSONObject: self) else {
            return defaultJsonStr
        }

        return String(data: data, encoding: .utf8) ?? defaultJsonStr
    }
}
